﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EmotionRecognitionEntities;
using EmotionRecognitionDB;

namespace EmotionRecognitionManager
{
    public  class InitialEndowment
    {//

        public InitialEndowment()
        {

        }
        //this method will activated when Accept Emotion button is pressed
       public void AcceptEmotion(int chunkId, Picture picture, int userID)
        {

            //  check if 1st round and  assign first chunk to picture 
            if (picture.ChunkID == -1)
            {
                picture.ChunkID = chunkId;
                picture.IsChecked++;
                DBQueries.UpdatePicturesinDB(picture);
                return;
            }

          
            
            // check if user was consistent in his second attempt
            if (picture.ChunkID == chunkId)
            {
                picture.IsChecked++;
                //if picture is consistent - accept emotion
                //1. create new case
                //2. add all picture au to list 
                if (picture.IsChecked == 2)
                {
                    DBQueries.AcceptEmotion(chunkId, picture.PictureID, userID);
                }
            }

            else
            {
                //if user isnt consistent - 
                //change old chunk of picture to new chunk
                //new chunk that given by the user.
                picture.ChunkID = chunkId;
            }


            DBQueries.UpdatePicturesinDB(picture);



        }
    }
}
